Ext.namespace('Ext.app.designer');

Ext.app.designer.MyBorderPanel = Ext.extend(Ext.Panel,{
	initComponent:function(){
		
		Ext.app.designer.windowHeight = Ext.getBody().getViewSize().height;
		Ext.app.designer.windowWidth = Ext.getBody().getViewSize().width;
		
		Ext.app.designer.westPanelWidth = 250;
		Ext.app.designer.eastPanelWidth = 0;
		Ext.app.designer.northPanelHeight = 50;
		Ext.app.designer.southPanelHeight = 0;
		
		Ext.app.designer.centerPanelWidth = (Ext.app.designer.windowWidth - (Ext.app.designer.westPanelWidth + Ext.app.designer.eastPanelWidth));
		Ext.app.designer.centerPanelHeight = (Ext.app.designer.windowHeight - (Ext.app.designer.northPanelHeight + Ext.app.designer.southPanelHeight));
		
		Ext.apply(this,{
			layout:'border',
			frame:false,
			border:false,
			items:[
				new Ext.app.designer.MyNorthPanel(),
				new Ext.app.designer.MyEastPanel(),
				new Ext.app.designer.MyCenterPanel(),
				new Ext.app.designer.MyWestPanel(),
				new Ext.app.designer.MySouthPanel()
			],
			listeners:{
				'afterrender':{
					fn : function(){
						Ext.EventManager.onWindowResize(this.resizeThreeScene , this);
					},scope:this
				}
			}
		});
		Ext.app.designer.MyBorderPanel.superclass.initComponent.apply(this);
	},
	
	resizeThreeScene : function(){
		Ext.app.designer.windowHeight = Ext.getBody().getViewSize().height;
		Ext.app.designer.windowWidth = Ext.getBody().getViewSize().width;
		
		Ext.app.designer.centerPanelWidth = (Ext.app.designer.windowWidth - (Ext.app.designer.westPanelWidth + Ext.app.designer.eastPanelWidth));
		Ext.app.designer.centerPanelHeight = (Ext.app.designer.windowHeight - (Ext.app.designer.northPanelHeight + Ext.app.designer.southPanelHeight));
		
		var ele = $('#sceneritor');
		
		ele.height(Ext.app.designer.centerPanelHeight);
		ele.width(Ext.app.designer.centerPanelWidth);
		
		Ext.app.designer.camera=new THREE.PerspectiveCamera(50,(Ext.app.designer.centerPanelWidth-20)/(Ext.app.designer.centerPanelHeight-20),1,100000);
		Ext.app.designer.camera.position.z = 100;
		Ext.app.designer.camera.position.y = 5;
		Ext.app.designer.scene.add(Ext.app.designer.camera);
		
		Ext.app.designer.renderer.setSize(Ext.app.designer.centerPanelWidth,Ext.app.designer.centerPanelHeight);
	}
});